//
//  BXPersonDataIdCell.m
//  BXlive
//
//  Created by bxlive on 2019/8/20.
//  Copyright © 2019 cat. All rights reserved.
//

#import "BXPersonDataIdCell.h"
#import <SLDeveloperTools/SLDeveloperTools.h>
#import <Masonry/Masonry.h>

@interface BXPersonDataIdCell ()

@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *contentLb;
//@property (nonatomic, strong) UIButton *getBtn;

@end

@implementation BXPersonDataIdCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor clearColor];
        [self createUI];
    }
    return self;
}

- (void)createUI {
    _titleLb = [UILabel initWithFrame:CGRectZero size:14 color:sl_textSubColors alignment:NSTextAlignmentLeft lines:1];
    _titleLb.font = SLPFFont(16);
    [self.contentView addSubview:_titleLb];
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(15);
    }];
  
//    _getBtn = [[UIButton alloc]init];
//    _getBtn.layer.cornerRadius = 13.5;
//    _getBtn.layer.masksToBounds = YES;
//    _getBtn.layer.borderColor = normalColors.CGColor;
//    _getBtn.layer.borderWidth = 1;
//    _getBtn.titleLabel.font = CFont(14);
//    [_getBtn setTitle:NSLocalizedString(@"复制", nil) forState:BtnNormal];
//    [_getBtn setTitleColor:normalColors forState:BtnNormal];
//    [_getBtn addTarget:self action:@selector(copyAction) forControlEvents:BtnTouchUpInside];
//    [self.contentView addSubview:_getBtn];
//    [_getBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.width.mas_equalTo(59);
//        make.height.mas_equalTo(27);
//        make.right.mas_equalTo(-15);
//        make.centerY.mas_equalTo(0);
//    }];
    
    _contentLb = [UILabel initWithFrame:CGRectZero size:14 color:sl_textSubColors alignment:NSTextAlignmentRight lines:1];
    _contentLb.font = SLBFont(16);
    [self.contentView addSubview:_contentLb];
    [_contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(self.titleLb.mas_right).offset(5);
        make.right.mas_equalTo(-__ScaleWidth(28));
    }];
    
//    UIView *lineView = [[UIView alloc]initWithFrame:CGRectZero];
//    lineView.backgroundColor = LineNormalColor;
//    [self.contentView addSubview:lineView];
//    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.height.mas_equalTo(.5);
//        make.bottom.mas_equalTo(0);
//        make.left.mas_equalTo(15);
//        make.right.mas_equalTo(0);
//    }];
}

- (void)setTitle:(NSString *)title subTitle:(NSString *)subTitle type:(NSInteger)type {
    _titleLb.text = title;
    _contentLb.text = subTitle;
    
//    _getBtn.hidden = !type;
    if (type) {
        [_contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.mas_equalTo(0);
            make.left.mas_equalTo(self.titleLb.mas_right).offset(5);
            make.right.mas_equalTo(-__ScaleWidth(28));
        }];
        
    } else {
        [_contentLb mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.mas_equalTo(0);
            make.left.mas_equalTo(self.titleLb.mas_right).offset(5);
            make.right.mas_equalTo(-__ScaleWidth(28));
        }];
    }
}

- (void)copyAction {
    [self becomeFirstResponder];
    UIPasteboard *pboard = [UIPasteboard generalPasteboard];
    pboard.string = _contentLb.text;
    [BGProgressHUD showInfoWithMessage:NSLocalizedString(@"复制成功", nil)];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
